package j03stream;

class Cat{
    String name;
    Cat next;

    public Cat(String name, Cat next) {
        this.name = name;
        this.next = next;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name+
                '}';
    }
}

public class J2lianshi {
    public static void main(String[] args) {
        Cat c1 = new Cat("加菲猫",null);
        Cat c2 = new Cat("加菲猫2",null);
        Cat c3 = new Cat("加菲猫3",null);

        c1.next = c2;
        c2.next = c3;

        System.out.println(c1);
        System.out.println(c1.next);
        System.out.println(c1.next.next);
        System.out.println(c1.next.next.name);
    }
}
